home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 36 / Amiga Format CD36 (1999-01-22)(Future Publishing)(GB)[!][issue 1999-02].iso / -seriously_amiga- / comms / other / makeftpscript / arexx / makeftpscript.rexx < prev   
OS/2 REXX Batch file  |  1998-11-30  |  2KB  |  85 lines

  1. /* MakeFTPScript v1.4 by Grzegorz Fitrzyk SP9WUN (sp9wun@sr9zaa.ampr.org)
  2.    
  3.    usage:    rx rexx:MakeFTPScript.rexx ADDRESS/K SOURCE/K DEST/K README/S
  4.    ex.:      rx rexx:MakeFTPScript.rexx ftp.wustl.edu ram:recent ram:script readme
  5.  
  6. */
  7.  
  8. parse arg ADDRESS source destin readflag
  9. parse var readflag ' ' readfl
  10.  
  11. MODE=''
  12. total=0
  13.  
  14. readfl=upper(readfl)
  15. destindx=destin||'.idx'
  16. options results
  17.  
  18. if Open(loadit, source, 'Read') then do    /* Open source file.*/
  19.   if Open(Saveit, destin, 'Write') then do /* Open destination file. */
  20.     if Open(Saveind, destindx, 'Write') then do /* Open index file. */
  21.       do forever
  22.         line=Readln(loadit)
  23.         if line="" then leave
  24.           parse var line '|'. header
  25.           if header="" then do
  26.             if line~="|" then do
  27.               call makeline
  28.             end
  29.           end
  30.         end
  31.     end; else call error_write
  32.   end; else call error_write
  33. end; else call error_read
  34.  
  35. say 'Total size of requested files 'total'KB'
  36. say 'Conversion succesfull.'
  37.  
  38. quitit:
  39. call close(saveit)
  40. call close(loadit)
  41. call close(saveind)
  42. address command 'c:filenote 'destin' 'total'KB'
  43. exit
  44.  
  45. error_read:
  46. say 'Cant find source file: 'source
  47. call quitit
  48.  
  49. error_write:
  50. say 'Cant write destination file 'dest
  51. call quitit
  52.  
  53. makeline:
  54. parse var line filename direct size rest
  55. tt2=pos('+',size)
  56. size2=size
  57. if tt2~=0 then parse var size2 size '+'
  58. linecom='ncftp'||MODE||' '||ADDRESS||':'||'pub/aminet/'||direct||'/'||filename
  59. call writeln(saveit,linecom)
  60. exten=right(size,1)
  61. if exten='?' then size='0K'
  62. temp=length(size)
  63. size=left(size,temp-1)
  64. size=translate(size,,' ')
  65. if exten="M" then size=size*1024
  66. total=total+size
  67. call doindex
  68. if readfl="README" then call doreadme
  69. return
  70.  
  71. doreadme:
  72. dlug=length(filename)
  73. readname=left(filename,dlug-3)
  74. linecom='ncftp'||MODE||' '||ADDRESS||':'||'pub/aminet/'||direct||'/'||readname||'readme'
  75. call writeln(saveit,linecom)
  76. size=0
  77. filename=readname||'readme'
  78. call doindex
  79. return
  80.  
  81. doindex:
  82. size=translate(size,,' ')
  83. indout=filename||' '||size
  84. call writeln(saveind,indout)
  85. return